﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

using Com.Yoeso.ORM.Common;
using Com.Yoeso.ORM.Framework;
using Com.Yoeso.ORM;

namespace Com.Yoeso.Entity
{
    [TableName("calendar_membership")]
    public class MemberShip : Persistent
    {
        public MemberShip()
        {
            id = "";
            eMail = "";
            password = "";
            username = "";
            sex = true;
            telephone = "";
            birthday = DateTime.Now;
            address = "";
        }

        #region 属性
        private string id;
        [TableColumn("ID", true), PrimaryKey(AutoGenerated = false)]
        public string ID
        {
            get { return id; }
            set { id = value; }
        }

        private string eMail;
        [TableColumn("EMail", true)]
        public string EMail
        {
            get { return eMail; }
            set { eMail = value; }
        }

        private string password;
        [TableColumn("Password", true)]
        public string Password
        {
            get { return password; }
            set { password = value; }
        }

        private string username;
        [TableColumn("Username", true)]
        public string Username
        {
            get { return username; }
            set { username = value; }
        }

        private bool sex;
        [TableColumn("Sex", true)]
        public bool Sex
        {
            get { return sex; }
            set { sex = value; }
        }

        private string telephone;
        [TableColumn("Telephone", true)]
        public string Telephone
        {
            get { return telephone; }
            set { telephone = value; }
        }

        private DateTime birthday;
        [TableColumn("Birthday", true)]
        public DateTime Birthday
        {
            get { return birthday; }
            set { birthday = value; }
        }

        private string address;
        [TableColumn("Address", true)]
        public string Address
        {
            get { return address; }
            set { address = value; }
        }        
        #endregion

        #region 方法

        public static MemberShip Retrieve(string id)
        {
            Key key = new Key(typeof(MemberShip), true, "ID", id);
            MemberShip obj = null;
            try
            {
                obj = SqlProvider.ORMBroker.RetrieveInstance(typeof(MemberShip), key) as MemberShip;
            }
            catch { }
            return obj;
        }

        public static MemberShip RetrieveByName(string eMail)
        {
            Key key = new Key(typeof(MemberShip), true, "EMail", eMail);
            MemberShip obj = null;
            try
            {
                obj = SqlProvider.ORMBroker.RetrieveInstance(typeof(MemberShip), key) as MemberShip;
            }
            catch (System.Exception ex)
            {
                string message = ex.Message;
            }
            return obj;
        }

        public static void Insert(MemberShip info)
        {
            SqlProvider.ORMBroker.Insert(info);
        }

        public static void Update(MemberShip info)
        {
            SqlProvider.ORMBroker.Update(info);
        }
        #endregion
    }
}
